package 测试;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

public class 火眼金睛 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int n = Integer.parseInt(sc.next());
			HashMap<Integer, ArrayList<Integer>> hm = new HashMap<Integer, ArrayList<Integer>>();
			for (int i = 0; i < n; i++) {
				int qid = Integer.parseInt(sc.next());
				int aid_num = Integer.parseInt(sc.next());
				ArrayList<Integer> aid = new ArrayList<Integer>();

				for (int j = 0; j < aid_num; j++) {
					aid.add(Integer.parseInt(sc.next()));
				}

				if (hm.containsKey(qid)) {
					ArrayList<Integer> al = hm.get(qid);
					for (int j = 0; j < al.size(); j++) {
						aid.add(al.get(j));
					}
					hm.put(qid, aid);
				} else if (!hm.containsKey(qid)) {
					hm.put(qid, aid);
				}
			}
			// System.out.println(hm.toString());
			System.out.println(func(n, hm));
		}
		sc.close();
	}

	public static String func(int n, HashMap<Integer, ArrayList<Integer>> hm) {
		HashSet<Integer> cheatSet = new HashSet<Integer>();
		ArrayList<Map.Entry<Integer, ArrayList<Integer>>> al = new ArrayList<Map.Entry<Integer, ArrayList<Integer>>>(
				hm.entrySet());
		for (int i = 0; i < al.size(); i++) {
			Integer key1 = al.get(i).getKey();
			ArrayList<Integer> value1 = al.get(i).getValue();
			for (int j = 0; j < al.size(); j++) {
				if (i == j) {
					continue;
				}
				Integer key2 = al.get(j).getKey();
				ArrayList<Integer> value2 = al.get(j).getValue();
				if (value2.contains(key1) && value1.contains(key2)) {
					cheatSet.add(key1);
				}
			}
		}

		for (int i = 0; i < al.size(); i++) {
			Integer key1 = al.get(i).getKey();
			ArrayList<Integer> value1 = al.get(i).getValue();
			int num = 0;
			for (int j = 0; j < value1.size(); j++) {
				Integer tmp = value1.get(j);
				if (cheatSet.contains(tmp)) {
					num++;
				}
			}
			if (num >= 2) {
				cheatSet.add(key1);
			}
		}

		Iterator<Integer> it = cheatSet.iterator();
		StringBuilder sb = new StringBuilder().append(cheatSet.size()).append("\n");
		while (it.hasNext()) {
			sb.append(it.next()).append(" ");
		}

		return sb.toString().trim();
	}

}
